<%@ page language="java" contentType="text/html; charset=utf-8"%>
<%@ include file="/commons/taglibs.jsp"%>
<%@ include file="/commons/commonList.jsp"%>

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>${key.title }</title>
<script type="text/javascript" src="${ctx}/scripts/common.js"></script>
<script language="javaScript" type="text/javascript"
		src="${ctx}/pages/com/ce/pms/charge/chargeVoucherPrint/searchInfoInit.js"></script>
<script type="text/javascript" src="${ctx}/scripts/common/prototype.js"></script>
<script type="text/javascript" src="${ctx}/scripts/common.js"></script>
<script type="text/javascript" src="${ctx}/scripts/ajaxException.js"></script>
<script type="text/javascript">

	//加载详细信息页面
	function showDetail(voucherId){
	   // var voucherId = document.getElementById("voucherId").value;
		var url = "${ctx}/charge_chargeVoucherPrintAction.do?method=initChargeVoucherDetail&voucherId="+voucherId;
		top.windowOpen(url, "chargeVoucherDetail", "收费项目详细", 560, 700);
	}

	//显示收费管理流程页面
	function showCycleForward(){
 		var url = "${ctx}/charge_chargeVoucherPrintAction.do?method=chargeCycleForwardSmall";
		top.windowOpen(url, "chargeCycleForward", "", 340, 900);
   }
   function cycleForward(url){
   		window.location.href=url;
   }

	//进行查询
   function searchInfo (){
   			$('s_ec_p').value=1;
	 		document.getElementById("findVoucherFrom").submit();
   }

   function init(){
	   	//设置收费周期的选中项
		var per = '${searchVO.period}';
		var leng=document.getElementById("period").options.length;
		var period = document.getElementById("period");
		for (var  i=0; i<leng; i++)
		{
	 		  if(per==period[i].value)
	 		  {
				period[i].selected="selected";
	  		  }
		}
		//设置楼栋选中项
		var bui = '${searchVO.building}';
		var leng=document.getElementById("building").options.length;
		var building = document.getElementById("building");
		for (var  i=0; i<leng; i++)
		{
	 		  if(bui==building[i].value)
	 		  {
				building[i].selected="selected";
	  		  }
		}
		//设置缴费方式选中项
		var paym = '${searchVO.payMethod}';
		var leng=document.getElementById("payMethod").options.length;
		var payMethod = document.getElementById("payMethod");
		for (var  i=0; i<leng; i++)
		{
	 		  if(paym==payMethod[i].value)
	 		  {
				payMethod[i].selected="selected";
	  		  }
		}
		//设置凭证状态选中项
		var sta = '${searchVO.statuz}';
		var leng=document.getElementById("statuz").options.length;
		var statuz = document.getElementById("statuz");
		for (var  i=0; i<leng; i++)
		{
	 		  if(sta==statuz[i].value)
	 		  {
				statuz[i].selected="selected";
	  		  }
		}
	}

	//进行打印(单条)
   function printVoucher (){
   $('voucherIds').value='';

   		var voucherId = document.getElementById("voucherId").value;
   		if (voucherId == null ||  voucherId == ""){
   			Alert("请选择一条数据进行打印!");
   			return ;
   		}

		url = "${ctx}/charge_chargeVoucherPrintAction.do?method=updateVoucherStart&voucherId="+voucherId;
		sendAjaxRequest(url,null,function(result){
			ajaxSubmitException(result.responseText);
			$('findVoucherFrom').submit();
		});

		$('printFrom').action ="${ctx}/applets/vouhcerAppletShow.jsp?reportName=ChargeVoucherReport&voucherId="+voucherId;
	 	$('printFrom').submit();
   }

	/**
	 *打印全部
	 */
   function printAll(){
   		var totalRows = '${totalRows}';
   		if (totalRows > 500){
   			Alert("要打印数据的不能大于500条,请重新选择！");
   			return ;
   		}

		var sortStr='${sortStr}';
   		var par = "&building=${searchVO.building}&period=${searchVO.period}"
   				+"&houseNumber=${searchVO.houseNumber}&participantName=${searchVO.participantName}"
   				+"&payMethod=${searchVO.payMethod}&voucherNum=${searchVO.voucherNum}&statuz=${searchVO.statuz}";
		var param =encodeURI(encodeURI(par));

		var url = "${ctx}/charge_chargeVoucherPrintAction.do?method=getVoucherPrintIds"+param+"&sortStr="+sortStr;
		sendAjaxRequest(url,null,function(result){
				var ids = result.responseText;

				url = "${ctx}/charge_chargeVoucherPrintAction.do?method=updateVoucherStart";
				new Ajax.Request(url,
			         { method:'post',
					   parameters:{voucherIds:ids},
					   onComplete:function(repost) {
							ajaxSubmitException(repost.responseText);
							$('findVoucherFrom').submit();
					   }
					 });

				$('voucherIds').value=ids;
				$('printFrom').action ="${ctx}/applets/vouhcerAppletShow.jsp?reportName=ChargeVoucherReport&sortStr="+sortStr;
			 	$('printFrom').submit();
		});
   }

	/**
	 *打印所选择
	 */
   function printChoose(){

   		var voucherIds = getSelectIds();

   		if(voucherIds==null ||voucherIds == "" ){
   			Alert('没有选择数据，请先选择数据！');
   			return ;
   		}

   		var sortStr = '${sortStr}';
   		url = "${ctx}/charge_chargeVoucherPrintAction.do?method=updateVoucherStart&sortStr="+sortStr;
   		new Ajax.Request(url,
			         { method:'post',
					   parameters:{voucherIds:voucherIds},
					   onComplete:function(repost) {
							ajaxSubmitException(result.responseText);
							$('findVoucherFrom').submit();
					   }
					 });

   		$('voucherIds').value=voucherIds;
		$('printFrom').action ="${ctx}/applets/vouhcerAppletShow.jsp?reportName=ChargeVoucherReport&sortStr="+sortStr;
	 	$('printFrom').submit();
   }

	/*单击数据行事件*/
	function onRowClick(voucherId,houseId){
		$('voucherId').value=voucherId;
		$('houseId').value=houseId;
	}

	/* 打开记录开票页面 */
	function openReceipt(){
		var voucherId = document.getElementById("voucherId").value;
   		if (voucherId == null ||  voucherId == ""){
   			Alert("请选择一条数据进行记录开票!");
   			return ;
   		}

		var url = "${ctx}/charge_chargeVoucherPrintAction.do?method=navigateReceipt&voucherId="+$('voucherId').value;
		top.windowOpen(url, "receiptPage", "记录开票", 300, 500);
	}

	//进行查询
   function refleshPage(){
	 	document.getElementById("findVoucherFrom").submit();
   }
</script>

</head>

<body onload="init();">
<form id="printFrom" name="printFrom" method="post"
		action="${ctx}/applets/vouhcerAppletShow.jsp?reportName=ChargeVoucherReport" target="_blank">
		<input type="hidden" id="voucherIds" name="voucherIds">
</form>

<div style="height:500px;overflow:auto;">

<div class="pageNav_bg">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
	<tr>
		<td id="pageNav_leftimg"><img src="${ctx}/images/ico_charge_pzdy.gif" width="46" height="47" /></td>
		<td id="navWord"><span class="page_title">${key.title }</span></td>
		<td class="pageNav_right"><a href="#" style="CURSOR: hand;" onFocus="this.blur()" onClick="showCycleForward()"><img src="${ctx}/images/charage_buzhou.gif" border="0"></a>&nbsp;&nbsp;
		<a href="javascript:showFull_in();"><img id="full_image" src="${ctx}/images/ico_fullscreen.gif" border="0" /></a></td>
	</tr>
</table>
</div>

<div class="container">
<table width="100%" border="0" cellpadding="0" cellspacing="0">

	  <tr>
	    <td class="bg_search2">
	    <!---------------------------------------------------------------------->
		<form id="findVoucherFrom" name="findVoucherFrom" method="post"
				action="${ctx}/charge_chargeVoucherPrintAction.do?method=initChargeVoucherMain"　
				class="required-validate">
	    <table border="0" cellpadding="0" cellspacing="1" class="tab_search2">
	      <tr>
				<td class="grid align_left">${key.building }：</td>
				<td><pms:unitedSelect style="width:110px;" name="building" value="keyword" dataList="${buildings}" selectText="${key.select }"
					optionLabel="name" optionValue="keyword"></pms:unitedSelect></td>
				<td class="grid align_left">${key.period }：</td>
				<td><pms:unitedSelect style="width:110px;" id="period" name="period" value="period" dataList="${periods}"
					selectText="${key.select }" optionLabel="period" optionValue="period"></pms:unitedSelect></td>
				<td class="grid align_left">${key.houseNumber }：</td>
				<td class="td_search"><input name="houseNumber" type="text" class="inputtext" size="16" value="${searchVO.houseNumber}"/>
				</td>
				<td class="grid align_left">${key.participantName }：</td>
				<td><input name="participantName" type="text" class="inputtext" size="16" value="${searchVO.participantName}" /></td>
				<td class="td_search">&nbsp;</td>
		</tr>
		<tr>
			<td class="grid align_left">${key.payMethod }：</td>
			<td><select id="payMethod" name="payMethod"  style="width:110px;">
					<option value="">${key.select }</option>
					<option value="001">现金</option>
					<option value="002">支票</option>
					<option value="003">刷卡</option>
					<option value="004">预交款抵冲</option>
					<option value="005">挂帐</option>
					<option value="006">多重支付</option>
					<option value="007">银行托收</option>
					<option value="010">押金抵冲</option>
				</select>
			</td>
			<td class="td_search">${key.voucherNumber }：</td>
			<td>
			<table border="0" cellspacing="0" cellpadding="0">
				<tr><td><input name="voucherNum" type="text" class="inputtext"  size="16" value="${searchVO.voucherNum }"/></td></tr>
			</table>
			</td>
			<td class="td_search">${key.statuz }：</td>
			<td class="td_search">
				<pms:unitedSelect style="width:110px;" name="statuz" value="value" dataList="${statuzs }"
					selectText="${key.select }" optionLabel="name" optionValue="value"></pms:unitedSelect></td>
			<td>&nbsp;</td>
			<td class="grid align_right">
			<table border="0" cellpadding="0" cellspacing="0">
				<tr>
					<td class="buttonOffLeft" id="btn1_11"></td>
					<td class="buttonOffMiddle" id="btn1_12" onblur="btn_change(1)" onMouseOver="btn_change_over(1)" onMouseOut="btn_change_out(1)" onclick="searchInfo();">
						<img src="${ctx}/images/ico_searchico.gif" alt="" border="0" align="absmiddle" /> ${key.find }</td>
					<td class="buttonOffRight" id="btn1_13"></td>
				</tr>
			</table>
			</td>
			<td>&nbsp;
			<input type="hidden" id="s_ec_crd" name="ec_crd" value="${pageSize }" >
			<input type="hidden" id="s_ec_p" name="ec_p" value="${currentlyPage }" >
			</td>
		</tr>

	</table>
	</form>
<!------------------------------------------------------------------------------->
	</td>
</tr>


<tr>
	<td width="100%" class="bg_toolBar" align="right">
	<table border="0" cellpadding="0" cellspacing="0" id="ico1">
		<tr>
			<td class="toolbarico">
				<input type="hidden" name="voucherId" id="voucherId" value="">
				<input type="hidden" name="houseId" id="houseId" value="">
				<c:if test="${list != null }"><a href="javascript:void(0)" onmouseover="showmenulist('quick_menumore',this)" onMouseOut="hidden2menu('quick_menumore')"><img src="${ctx}/images/ico_printer1.gif" border="0" align="absbottom"/></a></c:if>
				<c:if test="${list == null }"><a href="javascript:void(0)"> <img src="${ctx}/images/ico_printer.gif" border="0" align="absbottom"/></a></c:if>
			</td>
			<td>&nbsp;&nbsp;&nbsp;&nbsp;</td>
			<td class="toolbarico">
			    <c:if test="${list == null }"><img src="${ctx}/images/ico_kaipiao.gif" width="16" height="16" border="0" align="absbottom" />&nbsp;</c:if>
				<c:if test="${list != null }"><a href="#" onClick="openReceipt();"  onFocus="this.blur()"><img src="${ctx}/images/ico_kaipiao.gif" alt="记录开票" width="16" height="16" border="0" align="absbottom" /></a></c:if>
			</td>
			<td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>
		</tr>
	</table>
	</td>
</tr>

<tr>
	<td valign="top">
	<div class="tab_bgline">
	<ec:ceTable
		items="list"
		action="${ctx}/charge_chargeVoucherPrintAction.do?method=initChargeVoucherMain"
		var="item" view="pmsview" styleClass="gridData2" rowsDisplayed="10">
	<ec:ceRow id="${item.voucherId}"  styleClass="grid" onclick="onRowClick('${item.voucherId}','${item.houseId }');"
		onContextMenu="return ShowContextMenu(event,'quick_rightmenu');"
		ondblclick="showDetail('${item.voucherId }');">
		<ec:ceColumn headerCell="pmsHeadrCell" title="${key.building }" property="building" width="8%"></ec:ceColumn>
		<ec:ceColumn headerCell="pmsHeadrCell" title="${key.houseNumber }" property="houseNumber" width="6%" sortable="true"></ec:ceColumn>
		<ec:ceColumn headerCell="pmsHeadrCell" title="${key.period }" property="period" width="6%" sortable="true"></ec:ceColumn>
		<ec:ceColumn headerCell="pmsHeadrCell" title="${key.voucherNumber }" property="voucherNumber" width="10%"></ec:ceColumn>
		<ec:ceColumn headerCell="pmsHeadrCell" title="${key.participantName }" property="participantName" width="10%"></ec:ceColumn>
		<ec:ceColumn headerCell="pmsHeadrCell" title="${key.chargeDate }" property="chargeDate" width="7%"  cell="date" parse="yyyy-MM-dd"  sortable="true"></ec:ceColumn>
		<ec:ceColumn headerCell="pmsHeadrCell" title="${key.payMethod }" property="payMethod" width="8%"></ec:ceColumn>
		<ec:ceColumn headerCell="pmsHeadrCell" title="${key.sum }" property="sum" width="8%"></ec:ceColumn>
		<ec:ceColumn headerCell="pmsHeadrCell" title="${key.statuz }" property="statuz" width="5%"></ec:ceColumn>
		<ec:ceColumn headerCell="pmsHeadrCell" title="${key.isReceipt }" property="#" width="5%">
			<c:if test="${item.isReceipt}">是</c:if><c:if test="${!item.isReceipt}">否</c:if>
		</ec:ceColumn>
	</ec:ceRow>
	<ec:parameter name="ec_crd" value="${pageSize}"></ec:parameter>
	<ec:parameter name="ec_p" value="${currentlyPage}"></ec:parameter>
	<ec:parameter name="period" value="${searchVO.period }"></ec:parameter>
	<ec:parameter name="building" value="${searchVO.building }"></ec:parameter>
	<ec:parameter name="houseNumber" value="${searchVO.houseNumber}"></ec:parameter>
	<ec:parameter name="participantName" value="${searchVO.participantName }"></ec:parameter>
	<ec:parameter name="payMethod" value="${searchVO.payMethod }"></ec:parameter>
	<ec:parameter name="voucherNum" value="${searchVO.voucherNum }"></ec:parameter>
	<ec:parameter name="statuz" value="${searchVO.statuz }"></ec:parameter>
	</ec:ceTable>
	</div>
	</td>
</tr>
</table>
</div>


<div id="quick_rightmenu" style="display:none;"
	oncontextmenu="return false" class="quick_rightmenu"
	onMouseOver="MM_showHideLayers('quick_rightmenu')"
	onMouseOut="MM_showHideLayers('quick_rightmenu')">
<table width="100%" border="0" cellpadding="1" cellspacing="0"
	class="grid_quickMenu_bg">
	<tr>
		<td>
		<table width="100%" border="0" cellpadding="2" cellspacing="0">
			<tr>
				<td class="quickMenu_toolbarico"><a href="#"
					onClick="printVoucher();" onFocus="this.blur()"><img
					src="${ctx}/images/ico_printer.gif" alt="${key.print }" width="16"
					height="16" border="0" align="absbottom" />&nbsp;${key.print }</a></td>
			</tr>
		</table>
		</td>
	</tr>

	<tr>
		<td class="hrpading">
		<table width="95%" border="0" align="left" cellpadding="0" cellspacing="0">
		    <tr><td class="quickMenu_line"></td></tr>
		</table>
		</td>
	</tr>
	<tr>
        <td class="quickMenu_toolbarico">
          <a href="#" onclick="openReceipt();" onFocus="this.blur()">
          	<img src="${ctx}/images/ico_kaipiao.gif" alt="记录开票" width="16" height="16" border="0" align="absbottom">记录开票
          </a>
        </td>
    </tr>
</table>
</div>
</div>

<!-- 凭证打印类型选择 -->
<div id="quick_menumore" class="quick_menu2">
      <table width="100%" border="0" cellpadding="0" cellspacing="0" class="grid_quickMenu_bg" onMouseOver="showmy2menu('quick_menumore')" onMouseOut="hidden2menu('quick_menumore')">
        <tr>
          <td><table width="100%" border="0" cellpadding="0" cellspacing="0">

              <tr>
                <td class="quickMenu_toolbarico" id=""><a href="#" onClick="printAll();" ><img id="addBankAccountImg" src="${ctx}/images/ico_printer.gif"  border="0" align="absbottom"/>&nbsp;按查询打印</a></td>
              </tr>
              <tr>
                <td class="quickMenu_toolbarico" id=""><a href="#" onClick="printChoose();" ><img id="editBankAccountImg" src="${ctx}/images/ico_printer.gif"  border="0" align="absbottom"/>&nbsp;按选择打印</a></td>
              </tr>

                </table></td>
        </tr>
      </table>
</div>

</body>
</html>
